
from pysqlite2 import dbapi2 as sqlite
import datetime

con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES|sqlite.PARSE_COLNAMES)
#con = sqlite.connect("db.db", detect_types=sqlite.PARSE_DECLTYPES|sqlite.PARSE_COLNAMES)
cur = con.cursor()
cur.execute("create table test(d date, ts timestamp)")

today = datetime.date.today()
now = datetime.datetime.now()

cur.execute("insert into test(d, ts) values (?, ?)", (today, now))
#cur.execute("select d, ts from test")
con.commit()
cur.execute("select * from test;")
#row = cur.fetchone()

#print today, "=>", row[0], type(row[0])
#print now, "=>", row[1], type(row[1])

#cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"')
#row = cur.fetchone()



#print cur.fetchone()
#rows = cur.fetchall()

for row in cur:
    print "current_date", row[0], #, type(row[0])
    print "current_timestamp", row[1] #, type(row[1]) 

cur.close()
con.close()
